
#include "mypushbutton.h"
#include<QDebug>
#include<QPropertyAnimation>

mypushbutton::mypushbutton(QString nor1img,QString push1img)
{
    this->nor1=nor1img;
    this->push1=push1img;
    QPixmap pix;
    bool ret=pix.load(nor1img);
    if(!ret){
        qDebug()<<"加载错误";
        return;
    }
    this->setFixedSize(pix.width(),pix.height());
    this->setStyleSheet("QPushButton{border:0px;}");
    this->setIcon(pix);
    this->setIconSize(QSize(pix.width(),pix.height()));
}
void mypushbutton::zoom1(){
    QPropertyAnimation *ani=new QPropertyAnimation(this,"geometry");
    ani->setDuration(200);
    ani->setStartValue(QRect(this->x(), this->y(), this->width(), this->height()));
    ani->setEndValue(QRect(this->x(), this->y()+10, this->width(), this->height()));
    ani->setEasingCurve(QEasingCurve::OutBounce);
    ani->start();
}

void mypushbutton::zoom2(){

    QPropertyAnimation *ani=new QPropertyAnimation(this,"geometry");
    ani->setDuration(200);
    ani->setStartValue(QRect(this->x(), this->y()+10, this->width(), this->height()));
    ani->setEndValue(QRect(this->x(), this->y(), this->width(), this->height()));
    ani->setEasingCurve(QEasingCurve::OutBounce);
    ani->start();
}

